<template>
	<view class="card">
		<uv-qrcode ref="qrcode" class="qrcode" size="200px" :value="address" ></uv-qrcode>
		<view style="text-align: center;">邀请码  {{sheep.$store('user').userInfo.invitationCode}}</view>
	    
		
		<view class="downLoad" @click="downloadFn">
			<uni-icons type="pulldown" size="20"></uni-icons>
			<view>下载</view>
		</view>
	</view>
	
</template>

<script setup>
	import { computed,ref } from 'vue';
	import { onReady,onShow, onPageScroll, onPullDownRefresh,onLoad } from '@dcloudio/uni-app';
	import sheep from '@/sheep';
	
	const address=ref()
	const qrcode=ref(null)
	
	onLoad(()=>{
		console.log(sheep.$store('user').userInfo);
		console.log(sheep.$store('user').userInfo.invitationCode);
		address.value="http://zc.hfyinyi.cn/register.html?code="+sheep.$store('user').userInfo.invitationCode
	})
	onReady(()=>{
		
	})
	
	const downloadFn=()=>{
		qrcode.value.toTempFilePath({
			 success: (res) => {
			   console.log(res);
				uni.saveImageToPhotosAlbum({
					  filePath: res.tempFilePath,
					  success: function (response) {
						console.log(response);
						  uni.showToast({
							  title:'保存成功！'
						  })
					  },
					  fail: function (err) {
					  	  console.log(err);
						  uni.showToast({
						  	  title:'保存失败',
							  icon:'none'
						  })
					  },
					});
			 }
		})
	}
	
	
	
</script>

<style lang="scss"  scoped>
	page{
		padding-top: 40rpx;
	}
	.card{
		background-color: #fff;
		margin: 0 50rpx;
		padding:50rpx 0;
	}
	.qrcode{
		margin: 50rpx auto;
		// background-color: red;
	}
	.downLoad{
		display:flex;
		justify-content: flex-end;
		font-size: 30rpx;
		font-weight: 700;
		align-items: center;
		margin-right: 40rpx;
		margin-top: 50rpx;
	}
	
</style>